<%-- 
    Document   : user
    Created on : 18.5.2011, 19:36:
    Author     : Ruzin
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="com.zproekt.entity.Pacient" %>
<%@page import="com.zproekt.servis.OrdinacijaCRUD" %>
<%@page import="com.zproekt.entity.Termin" %>
<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<link rel="stylesheet" type="text/css" href="style.css" />

<f:view>
    <html>
        <head>
            <% 
            if (request.getSession().getValue("permisija") == null){
                response.sendRedirect("index.jsp?error=true");
            }
            String permisija = request.getSession().getValue("permisija").toString();
            if (permisija.equals("admin") || permisija.isEmpty()) {
              response.sendRedirect("index.jsp?error=true");
            }
        %>
            <% com.zproekt.entity.Pacient pacient = OrdinacijaCRUD.getPacient(Long.valueOf(request.getSession().getValue("id").toString()));
                pageContext.setAttribute("pacient", pacient);
                java.util.List<Termin> termin = OrdinacijaCRUD.getTerminUnijaPacient(Long.valueOf(request.getSession().getValue("id").toString()));
                pageContext.setAttribute("termin", termin);
            %>
            <% String greska = request.getParameter("error");
                if (greska != null) {
                    if (greska.equals("pominato")) {
                        out.println("<h1>Датумот е поминат!</h1>");
                    }
                    if (greska.equals("postoi")) {
                        out.println("<h1>Терминот е зафатен!</h1>");
                    }
                };
                String success = request.getParameter("success");
                if (success != null) {
                    if (success.equals("vnesenTermin")){
                        out.println("<h1>Терминот е закажан!</h1>");
                    }
                }
                
            %>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
            <title>${pacient.getIme()} ${pacient.getPrezime()}</title>
        </head>
        <body>
            <div class="head">
                <div class="text">
                    Добродојдовте на страната на стоматолошката ординација

                </div>
                <div class="logo"></div>
            </div> 


            <div style="width: 100%; height: 80px;">
                <div style="float: left;">
                    <h1>${pacient.getIme()} ${pacient.getPrezime()}</h1>   
                    <h2>ЕМБГ: ${pacient.getEmbg()}</h2>
                </div>
                <form action="logout.do" onsubmit="izvesti" style="float: right;padding: 5px;">
                    <input title="Одлогирај се!" type="submit" value="" class="buttonlogout"/></br>
                </form>
            </div>
            <div>
                <form action="userTermin.do">
                    Закажете термин:<br/>
                    Датум:<br/>
                    <input type="text" name="datum"/><br/>
                    Време:<br/>
                    <input type="text" name="vreme"/><br/>
                    <input type="submit" value="Закажи!"/>
                </form>
            </div>    
            <div style="width: 100%;">
                <c:forEach var="termin" items="${termin}">
                    <div style="margin-top:4px;margin-bottom: 4px; height: 2px;background-color: #490809;"></div>
                    <table style="padding: 5px;">
                        <tr>
                        <input type="text" value="${termin.getId()}" style="display: none" name="id"/>
                        <td style="padding: 5px;"> Датум на третман: </td>
                        <td style="padding: 5px;"> ${termin.getDatum()} </td>
                        </tr>
                        <tr>
                            <td style="padding: 5px;"> Време на третман: </td>
                            <td style="padding: 5px;"> ${termin.getVreme()}</td>
                        </tr>
                        <tr>
                            <td style="padding: 5px;"> Третман:</td>
                            <td style="padding: 5px;">${termin.getTretman()}</td>
                        </tr>
                    </table>
                </c:forEach>
            </div>
            <div style="margin-top:4px;margin-bottom: 4px; height: 2px;background-color: #490809;"></div>


            <div class="footer">
                Copyright Ruzin © 2011
            </div>
        </body>
    </html>
</f:view>
